<template>
  <div id="homeSwiper">
    <swiper :imgLoaded="imgLoaded">
      <swiper-item slot="slide" v-for="(item, index) in banner" :key="index">
        <a :href="item.link">
          <img :src="item.image" @load="itemLoaded" />
        </a>
      </swiper-item>
    </swiper>
  </div>
</template>

<script>
  import Swiper from '@commoncpn/swiper/Swiper.vue'
  import SwiperItem from '@commoncpn/swiper/SwiperItem.vue'

  export default {
    components: { Swiper, SwiperItem },
    data() {
      return {
        imgLoaded: false
      }
    },
    props: {
      banner: {
        type: Array
      }
    },
    methods: {
      itemLoaded() {
        this.imgLoaded = true
      }
    }
  }
</script>

<style scoped>
  a {
    display: block;
  }
</style>
